<?php

	require_once('inc_jiaju.php');

	define('UserPhotoPath','uploads/');	

	connect();

	$ctf_id = $_GET['id'];

	$sql="select * from jiaju where ctf_id={$ctf_id}";
	

	$result=mysql_query($sql);

	$row=mysql_fetch_assoc($result);

	$filename=UserPhotoPath.$row["pic"];

	//echo $filename;

	//删除数据库相应信息，如果删除成功，删除该用户的头像文件

	$sql1 = "delete from jiaju where ctf_id={$ctf_id}";

	$result = mysql_query($sql1) or die('删除失败！'.mysql_error());

	if(!mysql_error()){

		//如果有头像，则删除头像文件

		if($filename!=UserPhotoPath && file_exists($filename))

			unlink($filename);

		redirect('list.php', '删除成功！');

	}	

?>

